class Matrix {
//    矩阵，用于存储像素点等
}
abstract class ImageImp {
    public abstract void doPaint(Matrix m);
}
class WindowsImp extends ImageImp {
    public void doPaint(Matrix m) {
        //        传入矩阵，进行绘制
    }
}
class LinuxImp extends ImageImp {
    public void doPaint(Matrix m) {

    }
}
abstract class Image {
    protected ImageImp imp;
    public void setImp (ImageImp imp){
        this.imp = imp;
    };
    public abstract void parseFile(String fileName);
}
class BMPImage extends Image {
    private ImageImp imp;
    public void parseFile(String fileName) {
        // 解析BMP文件，并获得一个矩阵对象m
        Matrix m = new Matrix();
//        显示像素矩阵m
        imp.doPaint(m);
    }
}
class JPGImage extends Image {
    private ImageImp imp;
    public void parseFile(String fileName) {
        // 解析JPG文件
        Matrix m = new Matrix();
//        显示像素矩阵m
        imp.doPaint(m);
    }
}
class GIFImage extends Image {
    private ImageImp imp;
    public void parseFile(String fileName) {
        // 解析GIF文件
        Matrix m = new Matrix();
//        显示像素矩阵m
        imp.doPaint(m);
    }
}
public class Test {
    public static void main(String[] args) {
//        在Windows操作系统下显示BMP图片
        Image img = new BMPImage();
        ImageImp imp= new WindowsImp();
        img.setImp(imp);
        img.parseFile("小龙女");
    }
}
